'''
组合
多个模版使用管道进行链接，返回最终提示,完成组合提示模版功能
由一个字符串名称和一个提示模版组成的元组列表。每个提示模版进行格式化，然后作为相同名称的格式传递给未来的提示模版
'''
from langchain_core.prompts import PromptTemplate, PipelinePromptTemplate


def get_more_prompt_combination():


    full_template = """{introduction}

    {example}

    {start}"""
    full_prompt = PromptTemplate.from_template(full_template)

    # 说明提示模版-introduction
    introduction_template = """You are impersonating {person}."""
    introduction_prompt = PromptTemplate.from_template(introduction_template)

    # 问题提示模版-example
    example_template = """Here's an example of an interaction: 
    
    Q: {example_q}
    A: {example_a}"""
    example_prompt = PromptTemplate.from_template(example_template)

    # 问题模版-start
    start_template = """Now, do this for real!
    
    Q: {input}
    A:"""
    start_prompt = PromptTemplate.from_template(start_template)

    input_prompts = [
        ("introduction", introduction_prompt),
        ("example", example_prompt),
        ("start", start_prompt)
    ]
    pipeline_prompt = PipelinePromptTemplate(final_prompt=full_prompt, pipeline_prompts=input_prompts)
    pipeline_prompt.input_variables = ['example_a', 'person', 'example_q', 'input']
    prompt = pipeline_prompt.format(person="Elon Musk",example_q="What's your favorite car?",example_a="Telsa",input="What's your favorite social media site?")
    return prompt


